import { DataSource } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { config } from 'dotenv';
import { User } from "./src/user/entities/user.entity"
import { Role } from './src/user/entities/role.entity';
import { Permission } from './src/user/entities/permission.entity';
import { MeetingRoom } from './src/meeting-room/entities/meeting-room.entity';
import { Booking } from './src/booking/entities/booking.entity';
config();

export default new DataSource({
  type: 'mysql',
  host: "localhost",
  port: 3306,
  username: "root",
  password: "233233",
  database: "meeting_room_booking_system",
  // host: configServer.get('mysql_server_host'),
  // port: configServer.get('mysql_server_port'),
  // username: configServer.get('mysql_server_username'),
  // password: configServer.get('mysql_server_password'),
  // database: configServer.get('mysql_server_database'),
  // entities: [User, Role, Permission, MeetingRoom, Booking],
  synchronize: true,
  logging: true,
  poolSize: 10,
  connectorPackage: 'mysql2',
  extra:{
    authPlugins: 'sha256_password'
  },
  
  migrations: ['/migrations/*{.ts,.js}'],
  migrationsTableName: '_migrations',
  // migrationsRun: true,  // Auto-run migrations
  entities: ['dist/**/*.entity{.ts,.js}'],
});